<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends Controller {

	var $limit = 10;

	function Home()
	{
		parent::Controller();
		$this->load->library('auth');
		$this->load->library('fungsi');
		$this->load->model(array('setting_m', 'area_m'));
		$this->load->model('app_login_auth');
		$this->load->helper(array('text','app'));
	}	
	function index()
	{
		$this->data['graph'] = $this->creategraph();
		if ($this->session->userdata('login') == false)
		{
			//Definisi untuk memanggil function di libraries helper
			$this->load->helper('app');
			
			//Mengambil 10 data koleksi terbaru yang di upload
			$this->data['newUpload'] = $this->setting_m->getNewUpload('');
			//content body
			$this->data['content'] = 'home/home_v';
			$this->data['left'] = 'bg_left';
			$this->data['footer'] = 'footer';
			$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
			
			//Memanggil View
			$this->load->view('home/index', $this->data);
		}
		else if ( $this->session->userdata('login') == true && $this->session->userdata('akses') == 1)
		{
			redirect('admin');
		}
		else if ( $this->session->userdata('login') == true && $this->session->userdata('akses') == 3)
		{
			redirect('dosen');
		}
		else if ( $this->session->userdata('login') == true && $this->session->userdata('akses') == 4)
		{
			redirect('mahasiswa');
		}
	}
	
	function detail($id)
	{
		$this->data['graph'] = $this->creategraph();
		$this->load->helper('app');		
		//Mengambil 10 data koleksi terbaru yang di upload
		$this->data['newUpload'] = $this->setting_m->getNewUpload('');
		//content body
		$this->data['content'] = 'home/detail';
		$this->data['left'] = 'bg_left';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		$this->data['footer'] = 'footer';
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		
		$koleksi = $this->setting_m->getDataDetail($id);
		$author = $this->setting_m->getAuthor($id);
		$advisor = $this->setting_m->getAdvisor($id);
		$this->data['files'] = $this->setting_m->getFiles($id)->result();
		foreach ($koleksi as $k)
		{
			$path = base_url();
			$path .= "home/detail/";
			$path .= $id;
			$this->data['judul'] = $k->TITLE;
			$this->data['URI'] = $path;
			$this->data['date'] = $k->date;
			$this->data['abstract'] = $k->ABSTRACT;
			$NamaAuth = '';
			$NamaAdvis = '';
			if ($author->num_rows() > 0){
				foreach ($author->result() as $auth){
					$NamaAuth .= $auth->nama_penulis.' ('.$auth->jabatan_penulis.'), ';
				}
			}
			if ($advisor->num_rows() > 0){
				foreach ($advisor->result() as $advis){
					$NamaAdvis .= $advis->nama_pembimbing.' ('.$advis->jabatan_pembimbing.'), ';
				}
			}
			
			
			$this->data['author'] = $NamaAuth;
			$this->data['advisor'] = $NamaAdvis;
			
			
			// $this->data['nameFiles'] = $k->name_files;
			// $this->data['sizeFiles'] = $k->size_files;
			// $this->data['formatFiles'] = $k->type_files;
		}
		
		$this->load->view('home/index',$this->data);
		
	}
	
	function do_login()
	{
		$username    = $this->input->post('login_email', TRUE);
        $password    = $this->input->post('login_password', TRUE);
		$row = $this->app_login_auth->CheckUserDB($username, $password);
		if ( $row == '1')
		{
			redirect('admin/index');
		}
		else if ( $row == '3')
		{
			redirect('dosen/index');
		}
		else if ( $row == '4')
		{
			redirect('mahasiswa/index');
		}
		else
		{
			$this->session->set_flashdata('message','Username / Password Salah');//Kirim message ke form login
			redirect('home/login');
		}
	}
	function valid_captcha($str)
	{
		$expiration = time()-60;
		$this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration);
		$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? 
			    AND ip_address = ? AND captcha_time > ?";
		$binds = array($str, $this->input->ip_address(), $expiration);
		$query = $this->db->query($sql, $binds);
		$row = $query->row();	
		if ($row->count == 0) 
		{
			return FALSE;
		}else{
			return TRUE;
		}          
	}
	function logout()
	{
		$this->session->sess_destroy();
		redirect('home');
	}
	function front()
	{
		if(!is_logged_in())
		{
			$data = $this->auth->setChaptcha();
			$this->load->view('home/login_form',$data);
		}
		else
		{
			$data['title'] = '';
			$this->load->view('home/home_v',$data);
		}	
	}
	function login()
	{
		$this->data['graph'] = $this->creategraph();
		//content 
		$this->data['content'] = 'home/login_form_v';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		
		//Memanggil View
		$this->load->view('home/index', $this->data);
	}
	
	function forgotpassword()
	{
		$this->data['graph'] = $this->creategraph();
		//content 
		$this->data['content'] = 'home/forgotpassword';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		
		//Memanggil View
		$this->load->view('home/index', $this->data);
	}
	
	function Register()
	{
		$this->load->helper('app');
		$this->data['graph'] = $this->creategraph();
		//Mengambil 10 data koleksi terbaru yang di upload
		$this->data['newUpload'] = $this->setting_m->getNewUpload('');
		//content body
		$this->data['content'] = 'home/register';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		$this->data['error']= '';
		//Memanggil View
		$this->load->view('home/index', $this->data);
	}
	
	function do_register()
	{
		
		$this->load->helper('app');
		
		//Mengambil 10 data koleksi terbaru yang di upload
		$this->data['newUpload'] = $this->setting_m->getNewUpload('');
		//content body
		$this->data['content'] = 'home/register';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		
		$nim = $this->input->post('Noinduk', TRUE);
		$email = $this->input->post('Email', TRUE);
		$username = $this->input->post('Username', TRUE);
		$password = $this->input->post('password', TRUE);
		$confirmPwd = $this->input->post('txtUlangiPwd', TRUE);
		if ($nim&&$email&&$username&&$password&&$confirmPwd) {
			if (strlen($password)> 25 || strlen($confirmPwd)<6){
				$this->data['error']=  "Password harus antara 6-25 karakter";
				$this->data['default']['NoInduk'] = $nim;
					$this->data['default']['mail'] = $email;
					$this->data['default']['username'] = $username;
					$this->load->view('home/index', $this->data);
			}
			else {
			//untuk mengecek apakah form password dan form konfirmasi password sudah sama
				if ($password == $confirmPwd){
					$result = $this->setting_m->checkingRegister($username, $password, $email, $nim);
					$this->data['error']= $result;
					//Memanggil View
					$this->session->set_flashdata('message',$result);//Kirim message ke form login
					redirect('home/register');
				}
				else {
					$this->data['error']= 'Password yang anda masukan tidak sama!';
					//Memanggil View
					$this->data['default']['NoInduk'] = $nim;
					$this->data['default']['mail'] = $email;
					$this->data['default']['username'] = $username;
					$this->load->view('home/index', $this->data);
				}
			}
		}
		else
		{
			//Memanggil View
			$this->data['error']= 'Mohon Lengkapi Form Login';
			// redirect('home/register');
			$this->load->view('home/index', $this->data);
		}
	}
	
	function searchCollection($offseta = 0)
	{
		$this->data['graph'] = $this->creategraph();
		$query = $this->input->post('query', TRUE);
		$data = array('query' => $query);
		$this->session->set_userdata($data);
		$this->data['default']['query']  = $query;
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofKoleksi = $this->setting_m->get_ten_koleksiSearch($this->limit,$offseta, $query)->result();
		
			$tble = '';
			foreach ($tblofKoleksi as $tbKol)
			{
				
				$tble .= '<tr><td headers="t1" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->date.'</td>';
				$tble .= '<td headers="t2" class="evenRowOddCol">'.anchor('home/detail/'.$tbKol->id_collection,$tbKol->title).'</td>';
				$NamaAuth = '';
				$author = $this->setting_m->getAuthor($tbKol->id_collection);
				if ($author->num_rows() > 0){
						foreach ($author->result() as $auth){
							$NamaAuth .= $auth->nama_penulis.' ('.$auth->jabatan_penulis.'), ';
						}
					$tble .= '<td headers="t3" class="evenRowOddCol">'.$NamaAuth.'</td>';
				}
				$tble .= '</tr>';
			}
			$this->data['default']['tableKoleksiSearch'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	
	function advanced()
	{	
		$this->data['graph'] = $this->creategraph();
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		$this->data['ddlKeyword1'] = $this->fungsi->buildCriteriaDropdown('ddlKeyword1');
		$this->data['ddlKeyword2'] = $this->fungsi->buildCriteriaDropdown('ddlKeyword2');
		$this->data['ddlKeyword3'] = $this->fungsi->buildCriteriaDropdown('ddlKeyword3');
		//content body
		$this->data['content'] = 'advanced';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		$this->load->view('home/index', $this->data);
	}
	
	function do_advanced()
	{
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		$query1 = $this->input->post('query1', TRUE);
		$query2 = $this->input->post('query2', TRUE);
		$query3 = $this->input->post('query3', TRUE);
		
		$ddl1 = $this->input->post('ddlKeyword1', TRUE);
		$ddl2 = $this->input->post('ddlKeyword2', TRUE);
		$ddl3 = $this->input->post('ddlKeyword3', TRUE);
		
		$andOR1 = $this->input->post('conjunction1', TRUE);
		$andOR2 = $this->input->post('conjunction2', TRUE);
		
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		
		if($query1&&$query2&&$query3)
		{
			//3 advanced
		}
		else if ($query1&&$query2)
		{
			//2 advancde
		}
		else if ($query1)
		{
			//1 advanced
			$this->data['default']['tableKoleksiSearch'] = $this->setting_m->getCollection1($ddl1, $query1);
		}
		else
		{
			//Gagal
		}
		
		$this->load->view('home/index', $this->data);
	}
	
	function getFilter()
	{
		$this->data['graph'] = $this->creategraph();
		$query = $this->session->userdata('query');
		$TipeFilter = $this->input->post('filtertype', TRUE);
		$txtFilter = $this->input->post('filter',TRUE);
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		$this->data['searchResult'] = $this->setting_m->getCollectionCustome($query,$TipeFilter,$txtFilter);
		$this->data['test'] = $TipeFilter;
		$this->load->view('home/index', $this->data);
	}
	
	function sendMail()
	{
		$email    = $this->input->post('login_email', TRUE);
		$config = Array(
							'protocol'=> 'smtp',
							'smtp_host'=>'smtp.googlemail.com',
							'smtp_port'=>587,
							'smtp_user'=>'adityaprandhana@gmail.com',
							'smtp_pass'=>'remamberme29',
							'mailtype'=>'text',
							'charset'=>'iso-8559-1',
							'newline'=>"\r\n"
						);
		$this->load->library('email', $config);
		$this->email->from('adityaprandhana@gmail.com', 'aditya');
		$this->email->to($email);
		$this->email->subject('Email Test');
		$this->email->message('Test email function');
		$this->email->send();
		echo $this->email->print_debugger();
	}
	
	function sortBy()
	{
		if ($this->input->post('query', TRUE) == $this->session->userdata('query')){
			$query = $this->input->post('query', TRUE);
		}
		else{
			$query = $this->session->userdata('query');
		}
		$this->data['graph'] = $this->creategraph();
		$order = $this->input->post('sort_by', TRUE);
		$by = $this->input->post('order', TRUE);
		$limit = $this->input->post('rpp',TRUE);
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		
		$tblofKoleksi = $this->setting_m->getCollection($query,$order,$limit,$by)->result();
		
			$tble = '';
			foreach ($tblofKoleksi as $tbKol)
			{
				
				$tble .= '<tr><td headers="t1" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->date.'</td>';
				$tble .= '<td headers="t2" class="evenRowOddCol">'.anchor('home/detail/'.$tbKol->ID_COLLECTION,$tbKol->TITLE).'</td></tr>';
			}
			$this->data['default']['tableKoleksiSearch'] = $tble;
		
		$this->load->view('home/index', $this->data);
	}
	
	function download()
	{
		$akses = $this->session->userdata('akses');
		if ($akses == '1')
		{
			redirect('http://localhost:8888/repo/uploads/BAB_7_-_SWITCHING1.doc');
		}
	}
	
	function browsePenulis()
	{
		$this->data['graph'] = $this->creategraph();
		$query = $this->input->post('query', TRUE);
		$data = array('query' => $query);
		$this->session->set_userdata($data);
		$this->data['default']['query']  = $query;
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'home/browse';
		$this->data['left'] = 'bg_left';
		$this->data['actionSearch'] ='home/searchPenulis';
		$this->data['actionSort'] ='home/sortByPenulis';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		//Mengambil 10 data jenis koleksi yang baru diupload
		$this->data['newTypeUpload'] = $this->setting_m->getUploadFromTypeCollection();
		$this->data['searchResult'] = $this->setting_m->getCollection($query,'','','asc');
		$this->data['browseBy'] = 'Browse By Penulis';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofByAuthor = $this->setting_m->BrowseForAuthor(10,'','','asc')->result();
		
			$tble = '';
			foreach ($tblofByAuthor as $tbKol)
			{
				
				$tble .= ' <tr><td class="oddRowOddCol">';
				$tble .= anchor('home/DetailKoleksiPenulis/'.$tbKol->nim,$tbKol->nama);
				$tble .= ' </td></tr>';
			}
			$this->data['tableBrowse'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	function sortByPenulis($sort)
	{
		$this->data['graph'] = $this->creategraph();
		$limit = $this->input->post('rpp', TRUE);
		$by = $this->input->post('order', TRUE);
		if ($sort == "home" || $sort == false){
			$sort = "%";
		}
		if ($limit == false){
			$limit = 10;}
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'home/browse';
		$this->data['left'] = 'bg_left';
		$this->data['actionSearch'] ='home/searchPenulis';
		$this->data['actionSort'] ='home/sortByPenulis';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		$this->data['browseBy'] = 'Browse By Penulis';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofByAuthor = $this->setting_m->BrowseForAuthor($limit,$sort,' ',$by)->result();
		
			$tble = '';
			foreach ($tblofByAuthor as $tbKol)
			{
				
				$tble .= ' <tr><td class="oddRowOddCol">';
				$tble .= anchor('home/detail/'.$tbKol->nim,$tbKol->nama);
				$tble .= ' </td></tr>';
			}
			$this->data['tableBrowse'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	function searchPenulis()
	{
		$this->data['graph'] = $this->creategraph();
		$query = $this->input->post('starts_with', TRUE);
		$limit = $this->input->post('rpp', TRUE);
		$by = $this->input->post('order', TRUE);
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'home/browse';
		$this->data['left'] = 'bg_left';
		$this->data['actionSearch'] ='home/searchPenulis';
		$this->data['actionSort'] ='home/sortByPenulis';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		$this->data['browseBy'] = 'Browse By Penulis';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofByAuthor = $this->setting_m->BrowseForAuthor($limit,'%'.$query,' ',$by)->result();
		
			$tble = '';
			foreach ($tblofByAuthor as $tbKol)
			{
				
				$tble .= ' <tr><td class="oddRowOddCol">';
				$tble .= anchor('home/detail/'.$tbKol->nim,$tbKol->nama);
				$tble .= ' </td></tr>';
			}
			$this->data['tableBrowse'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	
	function browsePembimbing()
	{
		$this->data['graph'] = $this->creategraph();
		$query = $this->input->post('query', TRUE);
		$data = array('query' => $query);
		$this->session->set_userdata($data);
		$this->data['default']['query']  = $query;
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'home/browse';
		$this->data['left'] = 'bg_left';
		$this->data['actionSearch'] ='home/searchPembimbing';
		$this->data['actionSort'] ='home/sortByPembimbing';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		$this->data['browseBy'] = 'Browse By Pembimbing';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofByAuthor = $this->setting_m->BrowseForAdvisor(10,'','','asc')->result();
		
			$tble = '';
			foreach ($tblofByAuthor as $tbKol)
			{
				
				$tble .= ' <tr><td class="oddRowOddCol">';
				$tble .= anchor('home/DetailKoleksiPembimbing/'.$tbKol->nip,$tbKol->nama);
				$tble .= ' </td></tr>';
			}
			$this->data['tableBrowse'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	function sortByPembimbing($sort)
	{
		$this->data['graph'] = $this->creategraph();
		$limit = $this->input->post('rpp', TRUE);
		$by = $this->input->post('order', TRUE);
		if ($sort == "home" || $sort == false){
			$sort = "%";
		}
		if ($limit == false){
			$limit = 10;}
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'home/browse';
		$this->data['left'] = 'bg_left';
		$this->data['actionSearch'] ='home/searchPembimbing';
		$this->data['actionSort'] ='home/sortByPembimbing';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		$this->data['browseBy'] = 'Browse By Pembimbing';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofByAuthor = $this->setting_m->BrowseForAdvisor($limit,$sort,' ',$by)->result();
		
			$tble = '';
			foreach ($tblofByAuthor as $tbKol)
			{
				
				$tble .= ' <tr><td class="oddRowOddCol">';
				$tble .= anchor('home/detail/'.$tbKol->nip,$tbKol->nama);
				$tble .= ' </td></tr>';
			}
			$this->data['tableBrowse'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	function searchPembimbing()
	{
		$this->data['graph'] = $this->creategraph();
		$query = $this->input->post('starts_with', TRUE);
		$limit = $this->input->post('rpp', TRUE);
		$by = $this->input->post('order', TRUE);
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'home/browse';
		$this->data['left'] = 'bg_left';
		$this->data['actionSearch'] ='home/searchPembimbing';
		$this->data['actionSort'] ='home/sortByPembimbing';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		$this->data['browseBy'] = 'Browse By Pembimbing';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofByAuthor = $this->setting_m->BrowseForAdvisor($limit,'%'.$query,' ',$by)->result();
		
			$tble = '';
			foreach ($tblofByAuthor as $tbKol)
			{
				
				$tble .= ' <tr><td class="oddRowOddCol">';
				$tble .= anchor('home/detail/'.$tbKol->nip,$tbKol->nama);
				$tble .= ' </td></tr>';
			}
			$this->data['tableBrowse'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	
	
	function DetailKoleksiPenulis($NIM)
	{
		$this->data['graph'] = $this->creategraph();
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofKoleksi = $this->setting_m->DetailKoleksiPenulis($NIM)->result();
		
			$tble = '';
			foreach ($tblofKoleksi as $tbKol)
			{
				
				$tble .= '<tr><td headers="t1" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->date.'</td>';
				$tble .= '<td headers="t2" class="evenRowOddCol">'.anchor('home/detail/'.$tbKol->id_collection,$tbKol->title).'</td>';
				$tble .= '<td headers="t3" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->nama_penulis.'</td>';
				$tble .= '<td headers="t4" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->nama_pembimbin.'</td></tr>';
			}
			$this->data['default']['tableKoleksiSearch'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	
	function DetailKoleksiPembimbing($NIP)
	{
		$this->data['graph'] = $this->creategraph();
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofKoleksi = $this->setting_m->DetailKoleksiPembimbing($NIP)->result();
		
			$tble = '';
			foreach ($tblofKoleksi as $tbKol)
			{
				
				$tble .= '<tr><td headers="t1" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->date.'</td>';
				$tble .= '<td headers="t2" class="evenRowOddCol">'.anchor('home/detail/'.$tbKol->id_collection,$tbKol->title).'</td>';
				$tble .= '<td headers="t3" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->nama_penulis.'</td>';
				$tble .= '<td headers="t4" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->nama_pembimbin.'</td></tr>';
			}
			$this->data['default']['tableKoleksiSearch'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	
	function DetailKoleksiPerTipeKoleksi($kd)
	{
		$this->data['graph'] = $this->creategraph();
		$this->data['ddlJenisKol'] = $this->setting_m->getCboJenisKoleksi();
		//content body
		$this->data['content'] = 'search';
		$this->data['left'] = 'bg_left';
		$this->data['footer'] = 'footer';
		$this->data['account'] = $this->setting_m->getUploadFromTypeCollection();
		//header
		$this->data['header'] = 'bg_header';
		
		$uri_segment = 3;
		$offseta = $this->uri->segment($uri_segment);
		
		$tblofKoleksi = $this->setting_m->DetailKoleksiPerTipe($kd)->result();
		
			$tble = '';
			foreach ($tblofKoleksi as $tbKol)
			{
				
				$tble .= '<tr><td headers="t1" class="evenRowEvenCol" nowrap="nowrap" align="right">'.$tbKol->date.'</td>';
				$tble .= '<td headers="t2" class="evenRowOddCol">'.anchor('home/detail/'.$tbKol->id_collection,$tbKol->title).'</td>';
				$NamaAuth = '';
				$author = $this->setting_m->getAuthor($tbKol->id_collection);
				if ($author->num_rows() > 0){
						foreach ($author->result() as $auth){
							$NamaAuth .= $auth->nama_penulis.' ('.$auth->jabatan_penulis.'), ';
						}
					$tble .= '<td headers="t3" class="evenRowEvenCol" align="left">'.$NamaAuth.'</td>';
				}
				$tble .= '</tr>';
			}
			$this->data['default']['tableKoleksiSearch'] = $tble;
		
		
		$this->load->view('home/index', $this->data);
	}
	
	function creategraph()
	{
		$this->load->library('graph');
		$data_1 = array('30','20');
		// for( $i=0; $i<7; $i++ )
		// {
			// $data_1[] = rand(30,0);
		// }
		$ff = new graph();
		$ff->set_data( $data_1 );
		$ff->title( 'Trafic Collection', '{font-size: 14px; color: #3D5570;font-family:calibri;}' );
		$ff->line_dot( 3, 5, '#8B6122', 'Repository', 10 );
		$ff->bg_colour = '#FFFFFF';
		$ff->x_axis_colour( '#818D9D', '#ADB5C7' );
		$ff->y_axis_colour( '#818D9D', '#ADB5C7' );
		$ff->set_x_labels( array( '2013','2014') );
		$ff->set_y_max( 600 );
		$ff->y_label_steps( 10 );
		$ff->set_y_legend( 'Count', 12, '#3D5570' );
		$ff->set_x_legend( 'Year', 12, '#3D5570' );
		$ff->set_output_type('js');
		$ff->width = '100%';
		$ff->height = '100%';
		return $ff->render();
	}
	
}

/* End of file home.php */
/* Location: ./system/application/controllers/home.php */